/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sys.web;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.sys.entity.*;
import com.thinkgem.jeesite.modules.sys.service.AgentAddService;
import com.thinkgem.jeesite.modules.sys.service.WechatUserService;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 身份证审核Controller
 * @author huoyan403
 * @version 2016-10-29
 */
@Controller
@RequestMapping(value = "${adminPath}/sys/wechat")
public class WechatUserController extends BaseController {

	@Autowired
	private WechatUserService wechatUserService;
	@Autowired
	private AgentAddService agentAddService;
	//微信用户
	@RequestMapping(value ="tbuserList")
	public String list(TbUser tbUser, HttpServletRequest request, HttpServletResponse response, Model model) {
		User user = UserUtils.getUser();
		Page<TbUser> page = wechatUserService.findPage(new Page<TbUser>(request, response),tbUser);
		model.addAttribute("page", page);
		if(page.getList().size()==0){
			model.addAttribute("message1","无查询结果");
		}
		return "modules/sys/weChatUserList";
	}
	//微信用户
	@RequestMapping(value ="tbuserListByAgent")
	public String tbuserListByAgent(TbUser tbUser, HttpServletRequest request, HttpServletResponse response, Model model) {
		tbUser.setProvinces(UserUtils.getUser().getProvinces());
		tbUser.setCitys(UserUtils.getUser().getCitys());
		Page<TbUser> page = wechatUserService.findPage(new Page<TbUser>(request, response),tbUser);
		model.addAttribute("page", page);
		if(page.getList().size()==0){
			model.addAttribute("message1","无查询结果");
		}
		return "modules/sys/weChatUserList";
	}
	//物业钱包流水
	@RequestMapping(value ="tenementWallet")
	public String tenementWallet(TbTenementWalletStream tbTenementWalletStream, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<TbTenementWalletStream> page = wechatUserService.tenemenetStream(new Page<TbTenementWalletStream>(request, response),tbTenementWalletStream);
		model.addAttribute("page", page);
		if(page.getList().size()==0){
			model.addAttribute("message1","无查询结果");
		}
		/*<if test="address!=null and address!='' ">
		AND t.address like CONCAT('%', #{address}, '%')
		</if>*/
		return "modules/sys/wechatUseTenementWalletStream";
	}

	//麻雀钱包流水
	@RequestMapping(value ="mqWallet")
	public String mpWalletStream(TbMpWalletStream tbMpWalletStream, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<TbMpWalletStream> page = wechatUserService.mpWalletStream(new Page<TbMpWalletStream>(request, response), tbMpWalletStream);
		model.addAttribute("walletpage", page);
		return "modules/sys/wechatUseMpWalletStream";
	}
	@RequestMapping(value="isDelete")
	public String isDelete(TbUser tbUser, HttpServletRequest request, HttpServletResponse response, Model model){
		wechatUserService.isDelete(tbUser);
		String str=list(tbUser,request,response,model);
		return str;
	}
}